<?php

class QuestionModel extends Model {

    public function __construct() {
        parent::Model();
    }

    public function q_list($limit, $offset) {
        $this->db->limit($limit, $offset);
        $this->db->orderby('created_at','desc');
        return $this->db->get('question')->result();
    }

    public function find($id) {
        $this->db->where(array('id' => $id));
        $this->db->limit(1);
        $query = $this->db->get('question');
        return $query->num_rows > 0 ? $query->row() : false;
    }

    public function q_count() {
        return $this->db->count_all('question');
    }

    public function getAnwsers($id) {
        $this->db->where(array('question_id' => $id));
        $query = $this->db->get('anwser');
        return $query->num_rows > 0 ? $query->result() : false;
    }

}
